package org.jing.ext.web;

import org.jing.core.lang.annotation.IgnoreFieldToString;
import org.jing.core.lang.data.BaseDto;

import java.net.HttpURLConnection;
import java.util.List;
import java.util.Map;

/**
 * Description: <br>
 *
 * @author bksmate <br>
 * @since 2024-12-24 <br>
 */
public class ResponseEntity<T> extends BaseDto {
    private int statusCode;

    private WebHeaders headers;

    @IgnoreFieldToString
    private T body;

    public void setHeaders(Map<String, List<String>> headers) {
        this.headers = new WebHeaders();
        this.headers.putAll(headers);
    }

    public WebHeaders getHeaders() {
        return headers;
    }

    public T getBody() {
        return body;
    }

    public void setBody(T body) {
        this.body = body;
    }

    public int getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }

    public boolean isSuccess() {
        return statusCode == HttpURLConnection.HTTP_OK;
    }
}
